﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SYH.Utils
{
    public class ImgCodeTokenBuilder
    {
        public ImgCodeTokenBuilder()
        {
            //
            //TODO: 在此处添加构造函数逻辑
            //
        }
        public static string Md5(string str, int code)
        {
            string strEncrypt = string.Empty;
            if (code == 16)
            {
                strEncrypt = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").Substring(8, 16);
            }

            if (code == 32)
            {
                strEncrypt = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5");
            }

            return strEncrypt;
        }

        public string BuilderToken()
        {

            return Md5(DateTime.Now.Year.ToString() + "zhishengnet" + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Minute.ToString(), 32);

        }

    }
}
